<?php
namespace Admin\Controller;
//use Think\Controller;
class EducationController extends CommontController {
	//学历添加
	public function add(){
        $educationModel=D('Education');
        //学历添加实现
        if(IS_POST){
        	if($educationModel->create()){
        		if($educationModel->add()){
        			$this->success("添加成功",U("Education/index"));die;
        		}else{
        			$this->error("添加失败");
        		}
        	}else{
        		$this->error($educationModel->getError());
        	}
        }
        //渲染模板
        $this->display();
    }
    //学历列表
    public function index(){
    	$educationModel=D('Education');
        //分页操作
        $count=$educationModel->count();
        $page=new \Think\Page($count,10);
        $page->setConfig('prev','上一页');
        $page->setConfig('next','下一页');
        $this->pageList=$page->show();
        $list=$educationModel->limit($page->firstRow.','.$page->listRows)->select();
    	$this->assign('list',$list);
    	$this->display();
    }
    //学历修改
    public function upd(){
    	//实例化类模型
    	$educationModel=D('Education');
        //学历修改
    	if(IS_POST){
        	if($educationModel->create()){
        		if($educationModel->save()!==false){
        			$this->success("修改成功",U("Education/index"));die;
        		}else{
        			$this->error("修改失败");
        		}
        	}else{
        		$this->error($educationModel->getError());
        	}
        }
     	//系别分类回显
     	$edu_id=I('get.edu_id');
     	$list=$educationModel->find($edu_id);
        $this->assign('list',$list);
        $this->display();    	
    }
    //学历删除
    public function del(){
    	//实例化类模型
        $educationModel=D('Education');
    	$edu_id=I('get.edu_id');    	    	
		$data=$educationModel->delete($edu_id);
    	if($data){
    		$this->success("删除成功",U("Education/index"));die;
    	}else{
    		$this->error("删除失败");
    	}
	    
    }
}